package com.example.detectivedemo;

import com.example.detectivedemo.application.PlayerAppService;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.data.DatabaseHelper;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

/**
 * 应用主能力类
 * 负责应用的生命周期管理和初始化工作
 */
public class MainAbility extends Ability {
    
    private static final HiLogLabel LABEL = new HiLogLabel(HiLog.LOG_APP, 0x00200, "MainAbility");
    
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setMainRoute(MainAbilitySlice.class.getName());
        
        // 初始化应用服务
        initializeAppServices();
        
        HiLog.i(LABEL, "MainAbility onStart");
    }
    
    @Override
    public void onStop() {
        super.onStop();
        HiLog.i(LABEL, "MainAbility onStop");
    }
    
    @Override
    public void onActive() {
        super.onActive();
        HiLog.i(LABEL, "MainAbility onActive");
    }
    
    @Override
    public void onInactive() {
        super.onInactive();
        HiLog.i(LABEL, "MainAbility onInactive");
    }
    
    @Override
    public void onBackground() {
        super.onBackground();
        HiLog.i(LABEL, "MainAbility onBackground");
    }
    
    // 初始化应用服务
    private void initializeAppServices() {
        // 创建数据库助手
        DatabaseHelper databaseHelper = new DatabaseHelper(this);
        
        // 初始化玩家应用服务
        PlayerAppService.getInstance(databaseHelper);
        
        HiLog.i(LABEL, "App services initialized");
    }
}